package main

import (
	"fmt"
	"strings"
)

// 使括号有效的最少添加

func minAddToMakeValid(s string) int {
	for strings.Contains(s, "()") {
		s = strings.ReplaceAll(s, "()", "")
	}
	return len(s)
}

func main() {
	s := "())"
	res := minAddToMakeValid(s)
	fmt.Println(res)
}
